<template>
	<view class="p20">
		<view class="p24 bg-fff radius20">
			<view class="pr tit-ac fs30 flex1">
				<text>提现金额</text>
			</view>
			<view class="flex border-b pt20 pb20">
				<view class="fs30">￥</view>
				<input placeholder="请输入提现金额" v-model="money" class="fs36" />
			</view>
			<view class="pt20 flex">
				<view class="color-999">账户余额：</view>
				<view class="color-zs flex1">{{$user.deposit||'0'}}</view>
			</view>
		</view>
		<view class="tc pt20 pb20">- 提现方式 -</view>
		<view class="bg-fff p40 pl20 pr20 radius16" @click="setAccount()">
			<view class="fs30 fw-500 flex row-between">
				<block v-if="account">
					<view class="p14 bg-fff radius">
						<u-icon :name="iconList[account.method]" :color="colorList[account.method]" size="70" />
					</view>
					<view class="flex1 ml20">
						{{account.username}} {{account.account||'选择提现账户'}}
					</view>
				</block>
				<view class="flex1 ml20" v-else>选择提现账户 </view>
				<u-icon name="arrow-right" size="24" class="ml18"></u-icon>
			</view>
		</view>
		<view class="pt28 pb28">提现说明：</view>
		<view class="color-999 lh15">
			<text>{{$config.withdraw_tips}}</text>
		</view>
		<view class="h120"></view>
		<view class="pf left0 bottom0 w-max p20 h120 z-index2">
			<u-button type="error" class="w-max" @click="submit">提现</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// payList: [{
				// 	"name": '微信',
				// 	icon: 'weixin-circle-fill',
				// 	color: '#6bcc03',
				// 	type: 'wechat'
				// }, {
				// 	"name": '支付宝',
				// 	icon: 'zhifubao-circle-fill',
				// 	color: '#33c2fd',
				// 	type: 'alipay'
				// },{
				// 	"name": '银行卡',
				// 	icon: 'coupon-fill',
				// 	color: '#fcbd71',
				// 	type: 'alipay'
				// }],
				account: '',

				data: "",
				money: '',

				methodList: {
					"wechat": '微信',
					"alipay": '支付宝',
					"bank": '银行卡',
				},
				iconList: {
					"wechat": 'weixin-fill',
					"alipay": 'zhifubao',
					"bank": 'coupon-fill',
				},
				colorList: {
					"wechat": '#1bad1a',
					"alipay": '#2594c9',
					"bank": '#bab264',
				},
			};
		},
		onLoad() {
			this.getBalance()
		},
		methods: {
			submit() {
				let params = {
					money: this.money,
					bank_id: this.account.id
				}
				this.$request('/master/withdraw/withdraw', params).then(res => {
					this.$msg(res.msg)
					setTimeout(()=>{
						this.$u.route('/pages/my/balance/tixianLog')
					},1000)
				})
			},
			getBalance() {
				this.$request('/master/withdraw/accountList').then(res => {
					this.data = res.data
					this.account = res.data?.data?.find(e => e.is_default == 1)
				})
			},
			setAccount() {
				uni.$once('setAccount', e => this.account = e)
				this.$u.route('/pages/my/balance/bank', {
					type: 1,
					...this.$params
				})
			},
		}
	}
</script>

<style lang="scss">

</style>
